package com.bhs.sansonglogistics.ui.adapter;

import android.graphics.Color;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bhs.sansonglogistics.R;
import com.bhs.sansonglogistics.bean.MenuBean;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

public class PrivilegeAdapter extends BaseQuickAdapter<MenuBean, BaseViewHolder> {


    private int type = 1;//1金卡 2银卡

    public PrivilegeAdapter(@Nullable List<MenuBean> data) {
        super(R.layout.item_privilege, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder holder, MenuBean menuBean) {
        holder.setText(R.id.tv_name, menuBean.getMenuName()).setVisible(R.id.tv_name, menuBean.getMenuIcon() != 0);
        holder.setImageResource(R.id.iv_icon, menuBean.getMenuIcon()).setVisible(R.id.iv_icon, menuBean.getMenuIcon() != 0);
        holder.setText(R.id.tv_serial_number, String.format("0%s", holder.getLayoutPosition() + 1));
        holder.setBackgroundRes(R.id.ll_serial, type == 1 ? R.drawable.bg_under : R.drawable.bg_under2);
        holder.setTextColor(R.id.tv_serial_number, Color.parseColor(type == 1 ? "#CFA239" : "#FFFFFF"));
    }

    public void setType(int type) {
        this.type = type;
    }
}
